﻿using Little.Soldier.SWIFT;
using Little.Soldier.SWIFT.Definition;
using System.ComponentModel;

namespace Little.Soldier.SWIFT.Messages.Category0
{
  public class MTS21_FIN_ACKNAK : SwiftMessage
  {
    private static SwiftMessageDefinition MessageDefinition;
    private static SwiftTagDefinition U0002;
    private static SwiftTagSubItemDefinition U0003;
    private static SwiftTagSubItemDefinition U0004;
    private static SwiftTagSequenceDefinition U0005;
    private static SwiftTagDefinition U0006;
    private static SwiftTagSubItemDefinition U0007;
    private static SwiftTagSequenceDefinition U0008;
    private static SwiftTagDefinition U000E;
    private static SwiftTagSubItemDefinition U000F;
    private static SwiftTagSubItemDefinition U0010;
    private static SwiftTagDefinition U0011;
    private static SwiftTagSubItemDefinition U0012;

    [Description("Date and time, local to the user, of the Service Message 21 ACK/NAK.")]
    public Tag177 DateTime_177
    {
      get
      {
        return new Tag177((SwiftElement) this, 0, (SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0002);
      }
    }

    [Description("Date and time, local to the user, of the Service Message 21 ACK/NAK.")]
    public Tag177 Tag177_DateTime
    {
      get
      {
        return this.DateTime_177;
      }
    }

    [Description("Rejection Reason and Message User Reference")]
    public MTS21_FIN_ACKNAK.StatusAndMessageUserReferenceClass StatusAndMessageUserReference
    {
      get
      {
        return new MTS21_FIN_ACKNAK.StatusAndMessageUserReferenceClass((SwiftElement) this, 0, false);
      }
    }

    public MTS21_FIN_ACKNAK()
      : base(true)
    {
    }

    public MTS21_FIN_ACKNAK(SwiftMessage message)
      : base(message)
    {
    }

    internal override SwiftMessageDefinition MsgDefinition()
    {
      return MTS21_FIN_ACKNAK.MessageDefinition;
    }

    protected override void InitSwiftMessageDefinition()
    {
      MTS21_FIN_ACKNAK.MessageDefinition = new SwiftMessageDefinition("MTS21_FIN_ACKNAK", "Acknowledgement of a FIN Message Sent by an LT (ACK/NAK)");
      MTS21_FIN_ACKNAK.U0002 = new SwiftTagDefinition("DateTime_177", "Date and time, local to the user, of the Service Message 21 ACK/NAK.");
      MTS21_FIN_ACKNAK.U0002.TagName = "{177:";
      MTS21_FIN_ACKNAK.U0003 = new SwiftTagSubItemDefinition("Date", "Date");
      MTS21_FIN_ACKNAK.U0002.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0003);
      MTS21_FIN_ACKNAK.U0004 = new SwiftTagSubItemDefinition("Time", "Time");
      MTS21_FIN_ACKNAK.U0002.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0004);
      MTS21_FIN_ACKNAK.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0002);
      MTS21_FIN_ACKNAK.U0005 = new SwiftTagSequenceDefinition("StatusAndMessageUserReference", "Rejection Reason and Message User Reference");
      MTS21_FIN_ACKNAK.U0006 = new SwiftTagDefinition("AcceptReject_451", "Accepted or rejected");
      MTS21_FIN_ACKNAK.U0006.TagName = "{451:";
      MTS21_FIN_ACKNAK.U0007 = new SwiftTagSubItemDefinition("AcceptReject", "Accept or Reject");
      MTS21_FIN_ACKNAK.U0006.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0007);
      MTS21_FIN_ACKNAK.U0005.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0006);
      MTS21_FIN_ACKNAK.U0008 = new SwiftTagSequenceDefinition("RejectionReason_405", "Reason for rejection");
      MTS21_FIN_ACKNAK.U0008.Mandatory = false;
      MTS21_FIN_ACKNAK.U000E = new SwiftTagDefinition("RejectionReason", "Reason for rejection");
      MTS21_FIN_ACKNAK.U000E.TagName = "{405:";
      MTS21_FIN_ACKNAK.U000E.Mandatory = false;
      MTS21_FIN_ACKNAK.U000F = new SwiftTagSubItemDefinition("ErrorCode", "Error Code");
      MTS21_FIN_ACKNAK.U000E.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U000F);
      MTS21_FIN_ACKNAK.U0010 = new SwiftTagSubItemDefinition("LineTag", "");
      MTS21_FIN_ACKNAK.U0010.Mandatory = false;
      MTS21_FIN_ACKNAK.U000E.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0010);
      MTS21_FIN_ACKNAK.U0008.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U000E);
      MTS21_FIN_ACKNAK.U0005.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0008);
      MTS21_FIN_ACKNAK.U0011 = new SwiftTagDefinition("MessageUserReference_108", "Message User Reference");
      MTS21_FIN_ACKNAK.U0011.TagName = "{108:";
      MTS21_FIN_ACKNAK.U0011.Mandatory = false;
      MTS21_FIN_ACKNAK.U0012 = new SwiftTagSubItemDefinition("MessageUserReference", "Message User Reference");
      MTS21_FIN_ACKNAK.U0011.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0012);
      MTS21_FIN_ACKNAK.U0005.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0011);
      MTS21_FIN_ACKNAK.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0005);
    }

    public class StatusAndMessageUserReferenceClass : SwiftTagSequence
    {
      internal override SwiftDefinitionElement Definition
      {
        get
        {
          return (SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0005;
        }
      }

      [Description("Accepted or rejected")]
      public Tag451 AcceptReject_451
      {
        get
        {
          return new Tag451((SwiftElement) this, 0, (SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0006);
        }
      }

      [Description("Accepted or rejected")]
      public Tag451 Tag451_AcceptReject
      {
        get
        {
          return this.AcceptReject_451;
        }
      }

      [Description("Reason for rejection")]
      public MTS21_FIN_ACKNAK.StatusAndMessageUserReferenceClass.RejectionReason_405Class RejectionReason_405
      {
        get
        {
          MTS21_FIN_ACKNAK.StatusAndMessageUserReferenceClass.RejectionReason_405Class rejectionReason405Class = new MTS21_FIN_ACKNAK.StatusAndMessageUserReferenceClass.RejectionReason_405Class((SwiftElement) this, 0, false);
          if (this.ListTags((SwiftElement) rejectionReason405Class).Count > 0)
            return rejectionReason405Class;
          else
            return (MTS21_FIN_ACKNAK.StatusAndMessageUserReferenceClass.RejectionReason_405Class) null;
        }
      }

      [Description("Message User Reference")]
      public Tag108 MessageUserReference_108
      {
        get
        {
          return new Tag108((SwiftElement) this, 0, (SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0011);
        }
      }

      [Description("Message User Reference")]
      public Tag108 Tag108_MessageUserReference
      {
        get
        {
          return this.MessageUserReference_108;
        }
      }

      internal StatusAndMessageUserReferenceClass(SwiftElement parent, int index, bool createTags)
        : base(parent, index, createTags)
      {
      }

      public MTS21_FIN_ACKNAK.StatusAndMessageUserReferenceClass.RejectionReason_405Class AddRejectionReason_405()
      {
        return this.RejectionReason_405 ?? new MTS21_FIN_ACKNAK.StatusAndMessageUserReferenceClass.RejectionReason_405Class((SwiftElement) this, 0, true);
      }

      public void RemoveRejectionReason_405(MTS21_FIN_ACKNAK.StatusAndMessageUserReferenceClass.RejectionReason_405Class sequence)
      {
        foreach (SwiftTag tag in this.ListTags((SwiftElement) sequence))
          this.RemoveTag(tag);
      }

      public class RejectionReason_405Class : SwiftTagSequence
      {
        internal override SwiftDefinitionElement Definition
        {
          get
          {
            return (SwiftDefinitionElement) MTS21_FIN_ACKNAK.U0008;
          }
        }

        [Description("Reason for rejection")]
        public TagRejectionReason RejectionReason
        {
          get
          {
            return new TagRejectionReason((SwiftElement) this, 0, (SwiftDefinitionElement) MTS21_FIN_ACKNAK.U000E);
          }
        }

        internal RejectionReason_405Class(SwiftElement parent, int index, bool createTags)
          : base(parent, index, createTags)
        {
        }
      }
    }
  }
}
